package gemini.castor.ui.client.page.widget.categorypreview;

import com.google.gwt.event.shared.GwtEvent;

public class CategoryPreviewEvent extends GwtEvent<CategoryPreviewHandler> {

	private static Type<CategoryPreviewHandler> TYPE;
	
	public static Type<CategoryPreviewHandler> getType() {
		if (TYPE == null)
			TYPE = new Type<CategoryPreviewHandler>();
		return TYPE;
	}
	
	public enum ForwardType {
		SELECT;
	}
	
	public CategoryPreviewEvent(ForwardType forwardType) {
		super();
		this.setForwardType(forwardType);
	}
	
	private ForwardType forwardType;
	
	@Override
	protected void dispatch(CategoryPreviewHandler handler) {
		if(forwardType.equals(ForwardType.SELECT)){
			handler.onSelected(this);
		}
	}
	
	@Override
	public Type<CategoryPreviewHandler> getAssociatedType() {
		return getType();
	}

	public void setForwardType(ForwardType forwardType) {
		this.forwardType = forwardType;
	}

	public ForwardType getForwardType() {
		return forwardType;
	}
}
